#include <gui/healthpage_screen/HealthPageView.hpp>
#include <texts\TextKeysAndLanguages.hpp>
#include <images/BitmapDatabase.hpp>
HealthPageView::HealthPageView()
{

}

void HealthPageView::setupScreen()
{
    HealthPageViewBase::setupScreen();
}

void HealthPageView::tearDownScreen()
{
    HealthPageViewBase::tearDownScreen();
}
//健康监测信息上传
void HealthPageView::updateHeartRateInfo(uint32_t newHeartRate, uint32_t newSPO2)
{
		//更新脉搏
		if(newHeartRate > 40 && newHeartRate < 200 ) //限定数值范围
		{
			Unicode::snprintf(textPulseBuffer, TEXTPULSE_SIZE, "%d",newHeartRate);
			textPulse.invalidate();
			//更新显示数据
			dynamicGraphRate.addDataPoint((uint16_t) newHeartRate);
		}
		//更新血氧饱和度
		if(newSPO2 > 100 || newSPO2 <= 50 ) return;	//限定数值范围
		Unicode::snprintf(textSPOZBuffer, TEXTSPOZ_SIZE, "%d",newSPO2);
	  textSPOZ.invalidate();
}
//页面跳转
void HealthPageView::HealthPageChange(uint8_t newFiveKeyFunc)
{
		handleKeyEvent(newFiveKeyFunc);
}
//动画效果
void HealthPageView::handleTickEvent()
{
	static int timCnt = 0;
	timCnt++;	//20ms
	//
	if(timCnt <= 10)
	{
		scalableImageHeart.moveTo(115,175);
		//设置图片大小
		scalableImageHeart.setWidthHeight(51,47);
	}
	else if(timCnt <= 20)
	{
		scalableImageHeart.moveTo(129,187);
		//设置图片大小
		scalableImageHeart.setWidthHeight(25,24);
	}
	else //清除
	{
		timCnt = 0;
	}
	//显示
	scalableImageHeart.invalidate();
}